package com.example.ioc.component;

import com.example.ioc.model.UserInfo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

@Component
public class UserInfoComponent {



    //交给Spring来管理，各个包就都能用
    //@Bean需要配合五大注解来实现
    //一般不用重命名
    @Bean
    public UserInfo userInfo(){
        return new UserInfo("zhangsan",19);
    }

    //非唯一的Bean对象
   // @Primary
    @Bean
    public UserInfo userInfo1(){
        return new UserInfo("lisi",22);
    }
}
